public class MotiongramX {
  private PImage frame;
  private int currY;
  
  public MotiongramX(int w, int h) {
    this.frame = createImage(w, h, RGB);
    this.currY = 0;
  }
  
  public void setMarks(int thresh, float leftX, float rightX) {
    frame.set(thresh,currY,color(0,255,0));
    frame.set((int)leftX,currY,color(255,0,0));
    frame.set((int)rightX,currY,color(0,0,255));
  }
  
  public float[] process(PImage img) {
    float[] result = new float[img.width];
    currY = (currY + 1) % frame.height;
    for (int x = 0; x < img.width; x++) {
      for (int y = 0; y < img.height; y++) {
        result[x] += brightness(img.get(x,y));
      }
      result[x] /= cam.width;
      frame.set(x, currY, color(result[x]));
    }
    return result;
  }
  
  public void display(int x, int y) {
  //  image(frame,x,y);
  }
}
